/*
 * PyramideHistogramme.java Created on 24 avril 2007, 14:39 To change this template, choose Tools | Template Manager and open the template in the editor.
 */

package fr.limsi.seven;

import java.util.Iterator;
import java.util.LinkedList;

/**
 * @author amazaud
 */
public class PyramideHistogramme extends PyramideAbstractVariableNode {
	public static int PYRAMIDE_VARIABLE_TYPE_HISTOGRAMME = 1;

	@Override
	public int getVarType() {
		return PYRAMIDE_VARIABLE_TYPE_HISTOGRAMME;
	}

	/** Creates a new instance of PyramideHistogramme */
	public PyramideHistogramme(int varID, int nodeID, String varName) throws PyramideVariableException {
		super(varID, nodeID, varName);

		modalites = new LinkedList<PyramideVariableNodeModalite>();
	}

	public void createModalite(String nom_modalite, double value) {
		PyramideVariableNodeModalite mod = new PyramideVariableNodeModalite(value);
		modalites.add(mod);

		min_value = (value < min_value) ? value : min_value;
		max_value = (value > max_value) ? value : max_value;

		updateGlobalVarModalite(nom_modalite, mod);
	}

	@Override
	public String toString() {
		String out = new String("(var " + getVarID() + " node " + getVarNodeID() + ") Histogramme \"" + getVarName() + "\", " + modalites.size() + " modalit�(s)");
		for (Iterator<PyramideVariableNodeModalite> it = modalites.iterator(); it.hasNext();)
			out = out.concat("\n\t" + it.next());

		return out;
	}
}
